package org.jeecg.modules.meter.iot.command;

import com.alibaba.fastjson.JSONArray;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Description TODO
 * @Author huhouchun
 * @Date 2020/4/2 12:07
 * @Version 1.0
 */

@Service
@Slf4j
public class CommandInvoker {

    // IotCommand
    private IotCommand iotCommand;

    public void setIotCommand(IotCommand iotCommand) {
        this.iotCommand = iotCommand;
    }

    /**
     * 通用调用 命令
     * @param jsonParam
     * @param identifier
     * @return
     * @throws Exception
     */
    public boolean serviceInvoke (String jsonParam , String productKey , String requestUrl ,String requestMethod) throws Exception {
        return iotCommand.serviceInvoke(jsonParam ,  productKey , requestUrl,requestMethod);
    }

    /**
     * 需要返回值 命令
     * @param jsonParam
     * @param identifier
     * @return
     * @throws Exception
     */
    public String serviceInvokeWithData (String jsonParam , String identifier , String productKey , String deviceName)throws Exception {
        return iotCommand.serviceInvokeWithData(jsonParam , identifier ,  productKey ,  deviceName);
    }


    /**
     * 需要返回值 数组 命令
     * @param jsonParam
     * @param identifier
     * @param productKey
     * @param deviceName
     * @return
     * @throws Exception
     */
    public JSONArray serviceInvokeWithArrayData(String jsonParam ,  String productKey , String requestUrl ,String requestMethod)throws Exception {
        return iotCommand.serviceInvokeWithArrayData(jsonParam , productKey ,  requestUrl ,  requestMethod);
    }

}
